
package edu.cibertec.servicio;

import java.io.Reader;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

import com.ibatis.common.resources.Resources;
import com.ibatis.sqlmap.client.SqlMapClient;
import com.ibatis.sqlmap.client.SqlMapClientBuilder;

import edu.cibertec.bean.BeanArea; 
import edu.cibertec.bean.BeanIndicador;


public class AreaService {
	SqlMapClient sqlMap;
	
	public AreaService() {
		try {
			String resource = "SqlMapConfigApplication.xml";
			Reader reader = Resources.getResourceAsReader(resource);
			sqlMap = SqlMapClientBuilder.buildSqlMapClient(reader);
		} catch (Exception e) {
			e.printStackTrace();
			throw new RuntimeException(
				"Error cargando configuracion en " + this.getClass().getName() + "Cause: " + e);
		}
	}
	
	public ArrayList<BeanArea> getAreas(){
		ArrayList<BeanArea> listaArea = null;
		try {
			listaArea = (ArrayList<BeanArea>)sqlMap.queryForList("getAreas");
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return listaArea;
	}
}
